package 多线程;


import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

/**
 * @Author: 朱胜伟
 * @CreateTime: 2021-02-03 10:31
 * @Description:
 */
public class TTest {
    public static void main(String[] args) {
        PipedInputStream inputStream = new PipedInputStream();
        PipedOutputStream outputStream = new PipedOutputStream();
        try {
            inputStream.connect(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try{
//            outputStream.write("asdf\n".getBytes());
//            outputStream.write("cdsd".getBytes());
            outputStream.close();
            byte[] b1 = new byte[1024];
            inputStream.read(b1);
            String s = new String(b1);
            System.out.println(s);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
